<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
class Oauth_model extends CI_Model {
	public function __construct() {
		parent::__construct ();
	}
	/*
	 * 添加第三方登陆信息
	 */
	public function create($oauth){
		$this->db->insert('t_oauth', $oauth);
		return $this->db->insert_id();
	}
	/*
	 * 根据userid和type查找第三方登陆信息
	 */
	public function find_by_useridandtype($userid,$type){
		$this->db->where('userid', $userid);
		$this->db->where('type', $type);
		$query = $this->db->get('t_oauth');
		return $query->row_array();
	}
	/*
	 * 根据openid和type查找第三方登陆信息
	 */
	public function find_by_openidandtype($openid,$type){
		$this->db->where('openid', $openid);
		$this->db->where('type', $type);
		$query = $this->db->get('t_oauth');
		return $query->row_array();
	}
}
